#ifndef GUARD_vector_h
#define GUARD_vector_h

struct optimized_vector
{
   explicit optimized_vector(size_t size = 0);
   optimized_vector(const optimized_vector&);

   optimized_vector& operator =(const optimized_vector&);
   int& optimized_vector::operator[](size_t);
   const int optimized_vector::operator[](size_t) const;
   bool operator ==(const optimized_vector&) const;
   bool operator !=(const optimized_vector&) const;

   size_t size() const;
   void push_back(int);
   int pop_back();
   void reverse();
   int back() const;
   void swap(optimized_vector&);
   void resize(size_t new_size);
   ~optimized_vector();
   
private:
   union data
   {
      int* array;
      int number;
   };

   static const int VECTOR_RATIO = 2;

   data data_;
   size_t size_;
   size_t capacity_;

   void copy_data(const optimized_vector& a);
   size_t calculate_capacity(size_t new_size) const;
   void resize_if_necessary(size_t new_capacity);
   void resize_data(size_t new_capacity);
};

#endif